package com.gxh.shiro.exception;

import org.apache.shiro.authz.UnauthenticatedException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Xiaohong X Gou
 * @createTime 2023-04-12 15:10
 * @description
 */
@ControllerAdvice
@ResponseBody
public class PermissionsException {
    @ExceptionHandler(UnauthorizedException.class)
    public String unauthorizedException(Exception e){
        return "无权限";
    }
    @ExceptionHandler(UnauthenticatedException.class)
    public String authenticatedException(Exception e){
        return "权限认证失败";
    }
}
